package com.ft.admix.bd.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;

import com.ft.admix.ad.MixCustomNativeAd;
import com.kwad.sdk.api.KsFeedAd;

public class CustomKsFeedAd extends MixCustomNativeAd {
    KsFeedAd ksFeedAd;
    Activity mActivity;

    public CustomKsFeedAd(Activity activity, KsFeedAd ksNativeAd) {
        this.ksFeedAd = ksNativeAd;
        this.mActivity = activity;
        ksFeedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
            @Override
            public void onAdClicked() {
                callAdClick();
            }

            @Override
            public void onAdShow() {
                callAdShow();
            }

            @Override
            public void onDislikeClicked() {
                callDislikeSelected(0, "");
            }

            @Override
            public void onDownloadTipsDialogShow() {

            }

            @Override
            public void onDownloadTipsDialogDismiss() {

            }
        });
    }

    @Override
    public void render(ViewGroup viewGroup) {
        super.render(viewGroup);
        // 快手原生广告的渲染
        if (ksFeedAd != null) {

            ksFeedAd.render(new KsFeedAd.AdRenderListener() {
                @Override
                public void onAdRenderSuccess(View view) {
                    callRenderSuccess(0, 0);
                }

                @Override
                public void onAdRenderFailed(int i, String s) {
                    onAdRenderFailed(i, s);
                }
            });
            // 快手SDK的渲染方法可能不同，需要根据实际SDK文档调整
        }
    }

    @Override
    public View getExpressView(ViewGroup viewGroup) {
        viewGroup.removeAllViews();
        return ksFeedAd.getFeedView(mActivity);
    }

} 